package com.ray.eye.activity;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.ray.base.base.BaseActivity;
import com.ray.base.router.RouterActivityPath;
import com.ray.base.viewmodel.NoViewModel;
import com.ray.eye.R;
import com.ray.eye.databinding.ActivityDownloadSetBinding;

/**
 * 用户登陆
 **/
@Route(path = RouterActivityPath.EyeVideo.PAGER_DownloadSet)
public class DownloadSetActivity extends BaseActivity<ActivityDownloadSetBinding, NoViewModel> implements View.OnClickListener {

    static int DOWNLOAD_CLOSE = 0, DOWNLOAD_OPEN = 1;

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_download_set;
    }

    @Override
    public void initData() {
        binding.ivBack.setOnClickListener(this);
        binding.btnConfirm.setOnClickListener(this);
        //第一个写的是要读取的文件名
        SharedPreferences GetSet = getSharedPreferences("Set", MODE_PRIVATE);
        //第一个是获取关键词对应的内容，第二个是没获取到的话使用的默认值
        int set = GetSet.getInt("Set",0);
        if (set == 0){
            binding.rdClose.setChecked(true);
        }else {
            binding.rdOpen.setChecked(true);
        }
    }



    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.ivBack) {
            finish();
        }
        if (v.getId() == R.id.btn_confirm) {
            //第一个写的是保存的文件名
            SharedPreferences.Editor editor = getSharedPreferences("Set", MODE_PRIVATE).edit();
            if (binding.rdOpen.isChecked()) {
                editor.putInt("Set", DOWNLOAD_OPEN);
                editor.apply();
            } else {
                editor.putInt("Set", DOWNLOAD_CLOSE);
                editor.apply();
            }
            finish();
        }
    }
}
